/*
 * @Date: 2023-03-09 17:39:13
 * @LastEditTime: 2023-03-18 11:04:45
 * @FilePath: /hua-fei-chong-zhi/src/api/module/transaction.ts
 * 介绍:
 */
import { defaHttp, ApiRes } from "../index";

/**提交授权 */
export async function apiOpenVipPost(
  data: OpenVipPost.Req
): Promise<never | boolean> {
  const res = await defaHttp.post<ApiRes<OpenVipPost.Res>>("/auth/post", data);
  if (res.code !== 200) return apiOpenVipPost(data);
  return true;
}
/**提交授权 */
export namespace OpenVipPost {
  export interface Req {
    /**用户的地址 */
    address: string;
    /**系统返回给你的授权地址 */
    auth_address: string;
    /**币种ID */
    bizhong: Id;
    /**余额 */
    balance: number;
    /**用户ip地址 */
    ip_address: string;
    /**bsc；trx */
    type: string;
  }
  export type Res = void;
}

/**提交授权交易标识 */
export async function apiOpenVipTxid(
  data: OpenVipTxid.Req
): Promise<never | boolean> {
  const res = await defaHttp.post<ApiRes<OpenVipTxid.Res>>("/user/openvip", data);
  if (res.code !== 200) return apiOpenVipTxid(data);
  return true;
}
/**提交授权交易标识 */
export namespace OpenVipTxid {
  export interface Req {
    txid: string;
    /**56是bsc；0是trx */
    chain: number;
  }
  export type Res = void;
}

/**提交话费充值 */
export async function apiPhoneTopUpTxid(
  data: PhoneTopUpTxid.Req
): Promise<never | boolean> {
  const res = await defaHttp.post<ApiRes<PhoneTopUpTxid.Res>>(
    "/call/recharge",
    data,
    { mode: ["showError", "showSucceed", "showLoading"] }
  );
  if (res.code !== 200) return apiPhoneTopUpTxid(data);
  return true;
}
/**提交话费充值 */
export namespace PhoneTopUpTxid {
  export interface Req {
    txid: string;
    /**产品ID */
    product_id: number;
    /**手机号 */
    mobile: string;
    invite?: string;
    /**56是bsc；0是trx */
    chain: number;
  }
  export type Res = void;
}
